<%@ page import="com.scalar.chiptrack.commons.Constants"%>
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<style>
<!--
.HEADING     { cursor: hand; font-family: Verdana,Arial,San Serif; font-size: 12px; color: #000000;
               background-color: #FFFFFFF; font-weight: none;
               border: 1 solid #000000 }
-->
</style>

<Script Language="javascript">

function save()
{
    var form = document.fgiShipLotsForm.lotID;
    var count=0;
    var pa=document.getElementById("errors");
    var pa1=document.getElementById("svrErrors");
    pa1.innerHTML ='';
    var pa=document.getElementById("errors");

	// if there was only 1 transitID then previously there was a problem thus this code below
	if (typeof form.length =='undefined')
    {
		if (document.fgiShipLotsForm[ 'fgShipLotsList[0].checked' ].checked==true )
        {
            if ( isNaN( document.fgiShipLotsForm[ 'fgShipLotsList[0].recivedShipQty' ].value ) == true && document.fgiShipLotsForm[ 'fgShipLotsList[0].recivedShipQty' ].value != '' )
            {
                pa.innerHTML = '<li> Please enter a valid integer value for Received ShipQty.';
                document.fgiShipLotsForm[ 'fgShipLotsList[0].recivedShipQty' ].focus();
                return;
            }

			count = count+1;
        }

	}
	for( var i=0; i< form.length;i++ )
	{
		if( document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].checked' ].checked+""=='true' )
		{
            if ( isNaN( document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].value ) == true && document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].value != '' )
            {
                pa.innerHTML = '<li> Please enter a valid integer value for Received ShipQty.';
                document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].focus();
                return;
            }
            if ( eval(document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].value+"" ) > eval(document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].shipQty' ].value+"" )  )
            {
                pa.innerHTML = "<li>Received ShipQty Should not be greater than ShipQty </li>";
                document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].focus();
                return;
            }
			count++;
		}
	}
	if(count==0)
	{
		pa.innerHTML = "<li> Check one or more Checkboxes to Move the Qty to BLANK FGI";
		return;
	}
    var selId = document.fgiShipLotsForm.lotID;

    if ( selId.length == null )
    {
		if ( document.fgiShipLotsForm[ 'fgShipLotsList[0].checked' ].checked==true && document.fgiShipLotsForm[ 'fgShipLotsList[0].nextLocation' ].value == "" )
        {
            pa.innerHTML = "<li> Select Next Location for the selected part number ";
		    return;
        }
	}
    else
    {
        for( var i=0; i< selId.length;i++ )
        {
            if( document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].checked' ].checked+""=='true' && document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].nextLocation' ].value == "" )
            {
                 pa.innerHTML = "<li> Select Next Location for the selected part number ";
		        return;
            }
        }
    }
    document.fgiShipLotsForm.action="<%=chipTracContext%>/fgiShipLot.do?action=save";
    document.fgiShipLotsForm.submit();
}
/*To reset the Values */
function reset(){
    document.fgiShipLotsForm.reset();
}

/*To enter the Received Qty while selecting the checkbox,if deselecting the checkbox
Received Ship Qty field is disabled */
function setSelectAllIds(Object, idx)
{
    var selId = document.fgiShipLotsForm.lotID;

    if (typeof selId.length =='undefined')
    {
		if (document.fgiShipLotsForm[ 'fgShipLotsList[0].checked' ].checked==true )
        {
            document.fgiShipLotsForm[ 'fgShipLotsList[0].recivedShipQty' ].disabled = false;
            document.fgiShipLotsForm[ 'fgShipLotsList[0].recivedShipQty' ].focus();
            document.fgiShipLotsForm[ 'fgShipLotsList[0].recivedShipQty' ].value = document.fgiShipLotsForm[ 'fgShipLotsList[0].shipQty' ].value;
        }
        else
        {
            document.fgiShipLotsForm[ 'fgShipLotsList[0].recivedShipQty' ].disabled = true;
            document.fgiShipLotsForm[ 'fgShipLotsList[0].recivedShipQty' ].value = ''
        }
	}
    else
    {
        for( var i=0; i< selId.length;i++ )
        {
            if( document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].checked' ].checked+""=='true' )
            {
                document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].disabled = false;
                //document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].focus();
                document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].value = document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].shipQty' ].value;
            }
            else
            {
                document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].value = '';
                document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].recivedShipQty' ].disabled = true;
            }
        }
    }
}


/*code for restricting the user to enter numbers and decmals*/
function numcheck()
{
	if(((event.keyCode<48)||(event.keyCode>57)))
	{
		if(event.keyCode==46)
		{
			event.keyCode=0;
		}
		else
		{
			event.keyCode=0;
		}
	}
}

function disableVendor()
{
    var selId = document.fgiShipLotsForm.lotID;
    for( var i=0; i< selId.length;i++ )
    {

        if( document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].nextLocation' ].value == '' )
        {
            document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].nextLocation' ].disabled = false;
        }
        else
        {
            document.fgiShipLotsForm[ 'fgShipLotsList[' + i + '].nextLocation' ].disabled = true;
        }
    }
}


</Script>
</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload = "javascript:disableVendor()">
<html:form name="fgiShipLotsForm" type="com.scalar.chiptrack.operations.dataentry.forms.FGIShipLotsForm" action="/fgiShipLot">
<!-- Top Header Start-->
    <logic:equal name="fgiShipLotsForm" property="userType" value="1">
		<%@ include file="/jsp/includes/header.jsp" %>
	</logic:equal>
	<logic:equal name="fgiShipLotsForm" property="userType" value="0">
		<%@include file="/jsp/includes/extHeader.jsp"  %>
	</logic:equal>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
        <!-- Side Navigation start -->
        <logic:equal name="fgiShipLotsForm" property="userType" value="1">
            <%@ include file="/jsp/operations/dataentryMenu.jsp" %>
        </logic:equal>
        <logic:equal name="fgiShipLotsForm" property="userType" value="0">
		    <%@ include file="/jsp/admin/externaluser_menu.jsp" %></TD>
	    </logic:equal>
        <!-- end of the side navigations -->
    </TD>

   <TD bgcolor="#ffffff">
        <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8>
   </TD>
   <TD bgcolor="#ffffff">
        <IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2>
   </TD>

<TD valign="top" width="100%">

<IMG height=1 src="< %=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>


<!-- Start : In Transit Report -->

<TABLE width="100%" border="0">
    <TBODY>
    <TR>
    		<TD valign="top" bgcolor="#ffffff" >&nbsp;
				<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="8">
            </TD>
			<TD valign="top" >
                <IMG  src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width="500" height="1" border="0">
                <!-- Start : Report Block -->
				<table valign="top" width="100%" border="0">
                    <tr><td colspan="10" width="100%" align="center"><center><span class="NArialW">FGI Receipts </span></center></td></tr>
                       <logic:equal name="fgiShipLotsForm" property="userType" value="1">
                            <logic:present name="showMessage">
                                <logic:equal name="showMessage" value="TRUE">
                                    <TR><TD colspan='4' align='left'><font class='NArialS' color='blue'><B><%=Constants.NO_MODIFY_RIGHTS %></B></font></TD></TR>
                                </logic:equal>
                            </logic:present>
                        </logic:equal>
                    <tr><td colspan="10" class='NArialL'><FONT id="errors" styleClass="NArialL" color="#FF0000"></FONT></td></tr>
                    <tr><td colspan="10" id="svrErrors">
                            <chiptrack:errors styleClass="NArialL"/>
                            <chiptrack:info styleClass="NArialL"/>
                            <chiptrack:messages type="info" styleClass="NArialL" />
                        </td>

                    <bean:size id="LotsSize" name="fgShipLotsList" />
                    <logic:greaterThan name="LotsSize" value="0">
					<tr>
						<td colspan="10"class='NArialL'><font class='NArialS'><font color='blue'>[Click on Select checkbox to Move Qty to BLANK FGI  ]</font></font></td>
					</tr>
					<tr bgcolor="#993333" align = "center">
                        <td width="3%"><font class='NArialL'><font color="#FFFFFF">Select </font></font> </td>
						<td width="10%" nowrap><font class='NArialL'><font color="#FFFFFF">Part Number</font></font></td>
                        <td width="10%" nowrap><font class='NArialL'><font color="#FFFFFF">Lot No#</font></font></td>
						<td width="10%"><font class='NArialL'><font color="#FFFFFF">Ship Date</font></font></td>
						<td width="10%"><font class='NArialL'><font color="#FFFFFF">Ship Qty</font></font></td>
                        <td width="10%"><font class='NArialL'><font color="#FFFFFF">Vendor Name</font></font></td>
                        <td width="10%"><font class='NArialL'><font color="#FFFFFF">Received ShipQty</font></font></td>
                        <td width="10%"><font class='NArialL'><font color="#FFFFFF">Next Location</tr>
                     <nested:iterate id="fgShipLotsInfo" name="fgiShipLotsForm" property="fgShipLotsList" indexId="iterateIdx" type="com.scalar.chiptrack.operations.dataentry.InTransitLots">
                    <% if( Integer.parseInt( iterateIdx.toString() ) % 2 == 0 ) { %>
		            <tr bgcolor='#FFFFEE'>
		            <%} else { %>
		            <tr bgcolor='#DEE1E2'>
		            <% }
                        String jsFuntion = "setSelectAllIds(this,"+iterateIdx+")";
                    %>
                        <td width ="3%" align="center" ><font class='NArialL'><nested:checkbox name="fgShipLotsInfo" property="checked" onclick="<%=jsFuntion%>"/></td>
                        <td><font class='NArialL'><nested:write name="fgShipLotsInfo" property ="partNumber"/> </font></td>
                        <td><font class='NArialL'><nested:write name="fgShipLotsInfo" property ="lotNumber"/></font></td>
						<td><font class='NArialL'><nested:write name="fgShipLotsInfo" property ="shipDate"/></font></td>
						<td><font class='NArialL'><nested:write name="fgShipLotsInfo" property ="shipQty"/></font></td>
                        <td><font class='NArialL'><nested:write name="fgShipLotsInfo" property ="vendorName" /></font></td>
                        <td><font class='NArialL'><nested:text  name="fgShipLotsInfo" property ="recivedShipQty" onkeypress="javascript:numcheck()" styleClass="valuetxfield" disabled="true" maxlength="7" /></font></td>
                        <td><font class='NArialL'>
                            <nested:select name="fgShipLotsInfo" property="nextLocation" styleClass="txfield">
                                <html:option value="" >-- Select -- </html:option>
                                <html:options collection="CSLocations" property="label" labelProperty="label"></html:options>
                            </nested:select>
                            </font>
                         </td>
                        <nested:hidden name="fgShipLotsInfo" property="shippedLotID" ></nested:hidden>
                        <nested:hidden name="fgShipLotsInfo" property="shipQty" ></nested:hidden>
                        <nested:hidden name="fgShipLotsInfo" property="shipReqId" ></nested:hidden>
                        <input type="hidden" name="lotID"  value='LotsSize'>
                    </tr>
                    </nested:iterate>
                    </table>
                    <br>
                   <center>
                   <table>
                   <tr>
                   <td >
                    <logic:equal name="fgiShipLotsForm" property="userType" value="1">
                       <chiptrack:restrictedLink functionality='<%=Functionality.FGI_RECEIPTS%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:save()" onmouseover="window.status='Click here to Close the Transit Lots';return true" onmouseout="window.status='';return true">
                       <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></chiptrack:restrictedLink>
                    </logic:equal>
                    <logic:equal name="fgiShipLotsForm" property="userType" value="0">
                        <a href="javascript:save()" onmouseover="window.status='Click here to Close the Transit Lots';return true" onmouseout="window.status='';return true" title="Click here to Close the Transit Lots"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></a>                    </logic:equal>
                   </td>
                   <td>
                        <a href="javascript:reset()" onmouseover="window.status='Click here to Reset the Transit Lots';return true" onmouseout="window.status='';return true" title="Click here to Reset the Transit Lots"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
                   </td>
            </tr>
        </logic:greaterThan>
        <logic:lessEqual name="LotsSize" value="0">
            <br><br><br><br>
                <center>
                <tr>
                    <td colspan="10" class='NArialL' align="center"><FONT  styleClass="NArialL" color="#FF0000">No FGI ShipLots are Found</FONT>
                    </td>
                </tr>
                </center>
        </logic:lessEqual>
    </table>
 </center>
<!-- End : Report Block -->
<BR><BR><BR>
</TD>
</TR>
</TBODY>
</TABLE>
<!-- End : Lots InTransit Report -->
</html:form>
<BR><BR><BR>
</TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>
